package org.dromara.neutrinoproxy.client.controller;

import org.dromara.neutrinoproxy.client.config.ProxyConfig;
import org.dromara.neutrinoproxy.client.core.ProxyClientService;
import org.noear.solon.annotation.*;

@Mapping("/api/client")
@Controller
public class ClientLicenseController {

    @Inject ProxyClientService proxyClientService;
    @Inject ProxyConfig proxyConfig;

    @Get
    @Mapping("/license")
    public String page(@Param(value = "license", required = false) String license) {
        if(license == null || license.equals("")){
            return proxyClientService.getCurrentLicenseKey();
        }
//        proxyConfig.getClient().setLicenseKey(license);
        proxyClientService.setCurrentLicenseKey(license);
        proxyClientService.start();
        return license;
    }
}
